home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
cenvid
/
pathdel.bat
< prev
next >
Wrap
DOS Batch File
|
1994-10-05
|
1KB
|
49 lines
@echo off
REM *********************************************************
REM *** PathDel.bat - remove a directory from the current ***
REM *** ver.1 path if it's there ***
REM *********************************************************
if "%1"=="" GOTO SHOW_HOW
if not "%2"=="" GOTO SHOW_HOW
CEnviD %0.BAT %1
GOTO FINI
:SHOW_HOW
ECHO PathDel.bat - Delete a directory from the PATH if it's there
ECHO USAGE: PathDel DirSpec
GOTO FINI
GOTO CENVI_EXIT
main(argc,argv)
{
OldDir = argv[1]
if NULL == (Position = FindDirInPath(OldDir))
printf("The Directory \"%s\" is not in PATH.\n",OldDir)
else {
// copy from Path beyond this dir
strcpy(Position,Position+strlen(OldDir))
// if there is a semi-colon at this position, then copy from beyond that too
if (Position[0] == ';')
strcpy(Position,Position+1)
}
}
FindDirInPath(Dir) // search through path for this Dir, return pointer if found
// and return NULL if not found
{
len = strlen(Dir)
p = PATH
do {
if ( 0 == strnicmp(p,Dir,len) && (p[len]==0 || p[len]==';') )
return(p)
p = strchr(p,';')
} while( p++ != NULL )
return(NULL)
}
:CENVI_EXIT
:FINI